package vip.meeet.config;

import org.springframework.beans.factory.config.CustomEditorConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import vip.meeet.editor.DateEditor;

import java.beans.PropertyEditor;
import java.util.Date;
import java.util.HashMap;

@Configuration
@ImportResource({
        "classpath:spring-date.xml"
})
public class PropertyEditorConfig {

    @Bean
    public CustomEditorConfigurer getCustomEditorConfigurer(){
        CustomEditorConfigurer customEditorConfigurer = new CustomEditorConfigurer();
        HashMap<Class<?>, Class<? extends PropertyEditor>> map = new HashMap<>();
        map.put(Date.class, DateEditor.class);
        customEditorConfigurer.setCustomEditors(map);
        return customEditorConfigurer;
    }
}
